package com.wkr.order.dao;

import com.wkr.order.entity.TrainStoreEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Repository
public interface TrainStoreDao extends JpaRepository<TrainStoreEntity, Long> {

    @Transactional
    @Query(value = "update t_train_store set count = :leftCount, update_time= :updateTime where id = 999", nativeQuery = true)
    @Modifying
    int updateCountById(@Param("leftCount") Long leftCount, @Param("updateTime") LocalDateTime updateTime);
}
